package main

import (
	"changeLip/handler"
	"fmt"
	"github.com/go-chi/chi/v5"
	"github.com/go-chi/chi/v5/middleware"
	"log"
	"net/http"
	"time"
)

func main() {
	//使用chi框架 进行web中间件搭建
	r := chi.NewRouter()
	// A good base middleware stack
	r.Use(middleware.RequestID)
	r.Use(middleware.Logger)
	r.Use(middleware.Recoverer)
	// Set a timeout value on the request context (ctx), that will signal
	// through ctx.Done() that the request has timed out and further
	// processing should be stopped.
	r.Use(middleware.Timeout(60 * time.Second))
	r.Post("/upload", handler.Upload)
	r.Post("run", handler.Run)
	//r.Post("/upload", handler.Upload)
	log.Println(http.ListenAndServe(":9000", r))
	fmt.Println("server is listening on port 9000..")
}
